package com.gitee.feizns.webtemplate.commons.wechat;

import lombok.Data;

/**
 * 微信相关配置
 * @author feizns
 * @since 2019/4/12
 */
@Data
public class WeChatProperties {

    /**
     * 微信公众号，id
     */
    private String appId;

    /**
     * 微信公众密钥
     */
    private String appSecret;

    /**
     * 微信双向验证 token
     */
    private String token;

    public WeChatProperties(String appId, String appSecret, String token) {
        this.appId = appId;
        this.appSecret = appSecret;
        this.token = token;
    }

    public WeChatProperties() { }

    /**
     * 获取微信 access_token 请求链接
     */
    private String accessTokenUrl =
            "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";

    /**
     * js api 票据位置
     */
    private String jsApiTicketUrl =
            "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi";

    /**
     * js api 签名生成占位符
     */
    private String jsApiSignatureUrl =
            "jsapi_ticket={0}&noncestr={1}&timestamp={2}&url={3}";

    /**
     * 通过code换取网页授权access_token的url
     */
    private String authorizeUrl =
            "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code";

    /**
     * 如果网页授权作用域为snsapi_userinfo，则此时开发者可以通过access_token和openid拉取用户信息了。
     */
    private String authorizeUserInfoUrl =
            "https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}&lang=zh_CN";

    /**
     * 获取用户信息
     */
    private String userInfoUrl =
            "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN";

}
